<template>
  <el-row :gutter="16" class="panel-group">
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-icon-wrapper icon-money">
          <i class="iconfont icon-ruanjianguanli card-panel-icon" />
        </div> 
        <div class="card-panel-description">
          <div class="card-panel-text">
            在线资产：
          </div>
          <count-to :start-val="0" :end-val="topList.schoolOnlineCount" :duration="2600" class="card-panel-num" />
          <div class="card-panel-text">/</div>
          <count-to :start-val="0" :end-val="topList.schooltotalCount " :duration="2600" class="card-panel-num" />
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-icon-wrapper icon-message">
          <i class="iconfont icon-wangluo card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            高龄资产：
          </div>
          <count-to :start-val="0" :end-val="topList.deviceOnlineCount" :duration="2600" class="card-panel-num" />
          <!-- <div class="card-panel-text">/</div> -->
          <!-- <count-to :start-val="0" :end-val="topList.devicetotalCount " :duration="2600" class="card-panel-num" /> -->
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-icon-wrapper icon-people">
          <i class="iconfont icon-ruanjian card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            低配资产：
          </div>
          <count-to :start-val="0" :end-val="topList.netOnlineCount" :duration="2600" class="card-panel-num" />
          <!-- <div class="card-panel-text">/</div>
          <count-to :start-val="0" :end-val="topList.nettotalCount " :duration="2600" class="card-panel-num" /> -->
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-icon-wrapper icon-shopping">
          <i class="iconfont icon-Tab_ruanjianguanli card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            设备磁盘空间： 
          </div>
          <span class="card-panel-num">{{topList.DiskUsed}}</span>
          <div class="card-panel-text">/</div>
          <span class="card-panel-num">{{topList.DiskTotal}}</span>
          <!-- {{ topList.AmazonUsedSeconds }} -->
        </div>
      </div>
    </el-col>
  </el-row>
</template>

<script>
import { GetShadowURLSumGroupByAccessType, GetEventLog } from '@/api/firstPage.js'
import { getNowDay } from '@/utils/index.js'
import CountTo from 'vue-count-to'

export default {
  data(){
    return{
      block: 0,
      t:'/',
      accelerate: 0,
      passThrough: 0,
      eventNum: 0
    }
  },
  components: {
    CountTo
  },
  props:{
    topList:{}
  },
  // onload(){console.log("topList",topList);},
  created() {
    // this.getData()
    // this.GetEventLog()
  },
  methods: {
    async getData(){
      let NowDay = getNowDay('time')
      const data = {
        Filter: {
          StartTime: NowDay,
          EndTime: ""
        }
      }
      const res = await GetShadowURLSumGroupByAccessType(data)

      if(res.Data){
        let block = res.Data.filter(item => { return item.ClassID === 1})
        let accelerate = res.Data.filter(item => { return item.ClassID === 2})
        let passThrough = res.Data.filter(item => { return item.ClassID === 3})
        this.block = block.length > 0 ? block[0].Count * 1 : 0
        this.accelerate = accelerate.length > 0 ? accelerate[0].Count * 1 : 0
        this.passThrough = passThrough.length > 0 ? passThrough[0].Count * 1 : 0
      }
    }
    // async GetEventLog() {
    //   let NowDay = getNowDay('time')
    //   const data = {
    //     Paging: {
    //       QueryPageNo: 1,
    //       QueryPageLength: 10
    //     },
    //     Filter: {
    //       StartTime: NowDay,
    //       EndTime: ""
    //     }
    //   }
    //   const res = await GetEventLog(data)
    //   this.eventNum = res.Paging.TotalCount
    // }
  }
}
</script>

<style lang="scss" scoped>
.panel-group {
  .card-panel-col {
    margin-bottom: 16px;
  }

  .card-panel {
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 20px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);
    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-people {
        background: #40c9c6;
      }

      .icon-message {
        background: #36a3f7;
      }

      .icon-money {
        background: #f4516c;
      }

      .icon-shopping {
        background: #a834bf
      }
    }

    .icon-people {
      color: #40c9c6;
    }

    .icon-message {
      color: #36a3f7;
    }

    .icon-money {
      color: #f4516c;
    }

    .icon-shopping {
      color: #a834bf
    }

    .card-panel-icon-wrapper {
      float: left;
      padding: 5px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 20px;
    }

    .card-panel-description {
      height: 40px;
      display: flex;
      align-items: center;
      font-weight: bold;
      margin: 5px;
      margin-left: 0px;
      .card-panel-text {
        line-height: 14px;
        margin-right: 15px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 18px;
      }
      .card-panel-num {
        color: rgba(0, 0, 0, 0.45);
        font-size: 18px;
        margin-right: 10px;
      }
    }
  }
}

@media (max-width:550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
